package domain.terrain;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

public class MatrixComponent {
	
	private BufferedImage map;
	private int solidRGB;
	
	public MatrixComponent(BufferedImage map){
		this.map = map;
		this.solidRGB = (Color.BLACK).getRGB();
	}
	

	
	public boolean isCollision(double nX, double nY, int width, int height) {

		int x = (int) Math.round(nX);
		int y = (int) Math.round(nY);

		for (int i = x; i < x + width; i++) {
			for (int ii = y; ii < y + height; ii++) {
				if (i < this.getWidth() & i > 0 & ii < this.getHeight()
						& ii > 0) {
					if (this.solidPixel(this.map.getRGB(i, ii))) {
						return true;
					}
				}
			}
		}
		return false;
	}
	
	public boolean solidPixel(int rgb) {
		return rgb == this.solidRGB;
	}
	
	public int getWidth() {
		return this.map.getWidth();
	}


	public int getHeight() {
		return this.map.getHeight();
	}

}
